package netty;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.util.concurrent.EventExecutorGroup;

import java.nio.ByteBuffer;

public class MyHandler extends SimpleChannelInboundHandler<ByteBuffer> {
    protected void channelRead0(ChannelHandlerContext ctx, ByteBuffer msg) throws Exception {
        String request = new String(msg.array());
        System.out.println(request);
        String response = "say hello to " + request;
        ctx.channel().write(ByteBuffer.wrap(response.getBytes()));
        ctx.channel().write(ByteBuffer.wrap("\n".getBytes()));
    }
}
